<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8">
    <title>医废追溯</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_739294_4v71dzenelg.css" media="all">
    <style type="text/css">
        .laytable-cell-radio.layui-table-cell {
            padding: 0 5px 0 15px;
        }
        
        .laytable-cell-radio span {
            display: none;
        }
        
        .laytable-cell-radio .layui-form-radio {
            padding-right: 0;
            margin: 0;
        }
    </style>
</head>

<body>
    <div class="layui-form" style="margin-left:20px;margin-top:15px;margin-bottom:-20px">
        <div class="layui-form-item">
            <label class="layui-form-label">袋子条形码</label>
            <div class="layui-inline">
                <input class="layui-input" name="id" id="demoReload" autocomplete="off" placeholder="请输入条形码">
            </div>
            <div class="layui-btn-group">
                <button class="layui-btn" data-type="reload" id="serch"> <i class="layui-icon">&#xe615;</i>查询</button>
                <button class="layui-btn" data-type="reload" id="screen"><i class="iconfont icon-xuanzexiangmu"></i>表头筛选</button>
            </div>
        </div>
    </div>
    <table id="demo" lay-filter="test"></table>
    <script src="../../layuiadmin/layui/layui.js"></script>
    <script>
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index']);
        layui.use('laydate', function() {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#datetime' //指定元素
            });
        });
        var cols = [ //表头
            {
                field: 'hname',
                title: '医院名称',
                width: '20%'
            }, {
                field: 'code',
                title: '袋子条码',
                width: '11%'

            }, {
                field: 'sno',
                title: '条形码',
                width: '11%'
            }, {
                field: 'type',
                title: '类别',
                width: '10%',
                templet: function(d) {
                    switch (d.type) {
                        case "0":
                            return "感染性废物";
                            break;
                        case "1":
                            return "损伤性废物";
                            break;
                        case "2":
                            return "利器盒";
                            break;
                        case "3":
                            return "化学性废物";
                            break;
                        case "4":
                            return "药物性废物";
                            break;
                        case "5":
                            return "病理性废物";
                            break;
                    }
                }

            }, {
                field: 'pdate',
                title: '收集日期',
                width: '8%'
            }, {
                field: 'time',
                title: '收集时间',
                width: '11%'
            }, {
                field: 'custname',
                title: '产废点名称',
                width: '7%'
            }, {
                field: 'areaname',
                title: '关联科室',
                width: '7%'
            }, {
                field: 'ename',
                title: '收集人员',
                width: '7%'
            }, {
                field: 'sname',
                title: '审核人员',
                width: '7%'
            }
        ];
        layui.use('table', function() {
            var table = layui.table;
            var $ = layui.$;
            var tableIns = table.render({
                elem: '#demo',
                height: 'full',
                data: [],
                cols: [
                    cols
                ],
                skin: 'row' //表格风格
                    ,
                even: true
            });
            var alos = cols;
            $("#screen").on('click', function() {
                cols = [ //表头
                    {
                        field: 'hname',
                        title: '医院名称',
                        width: '20%'
                    }, {
                        field: 'code',
                        title: '袋子条码',
                        width: '11%'

                    }, {
                        field: 'sno',
                        title: '条形码',
                        width: '11%'
                    }, {
                        field: 'type',
                        title: '类别',
                        width: '10%',
                        templet: function(d) {
                            switch (d.type) {
                                case "0":
                                    return "感染性废物";
                                    break;
                                case "1":
                                    return "损伤性废物";
                                    break;
                                case "2":
                                    return "利器盒";
                                    break;
                                case "3":
                                    return "化学性废物";
                                    break;
                                case "4":
                                    return "药物性废物";
                                    break;
                                case "5":
                                    return "病理性废物";
                                    break;
                            }
                        }

                    }, {
                        field: 'pdate',
                        title: '收集日期',
                        width: '8%'
                    }, {
                        field: 'time',
                        title: '收集时间',
                        width: '11%'
                    }, {
                        field: 'custname',
                        title: '产废点名称',
                        width: '7%'
                    }, {
                        field: 'areaname',
                        title: '关联科室',
                        width: '7%'
                    }, {
                        field: 'ename',
                        title: '收集人员',
                        width: '7%'
                    }, {
                        field: 'sname',
                        title: '审核人员',
                        width: '7%'
                    }
                ];
                layer.open({
                    type: 2,
                    title: ['表头筛选', 'background:#19A094;color:white;font-size:17px;font-weight:bold'],
                    area: ['450px', '330px'],
                    offset: 'auto',
                    content: 'packagescreen.html',
                    btn: ['确认', '取消'],
                    success: function(layero, index) {
                        var body = layer.getChildFrame('body', index);
                        for (var k = 0; k < alos.length; k++) {
                            body.find("#" + alos[k].field).prop("checked", true);
                        }
                    },
                    yes: function(index, layero) {
                        var body = layer.getChildFrame('body', index);
                        var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();

                        var a = iframeWin.a();
                        for (var i = 0; i < a.length; i++) {
                            for (var j = 0; j < cols.length; j++) {
                                if (a[i] == cols[j].field) {
                                    cols.splice(j, 1)
                                }
                            }
                        }
                        alos = cols;
                        tableIns.reload({
                            cols: [cols]
                        });
                        layer.close(index);
                        $("table tr").css({
                            "background": "#19A094",
                            "color": "white"
                        });
                    }
                })
            })
            $("#serch").on('click', function() {
                tableIns.reload({
                    url: '../../../Box/smallCurr',
                    where: {
                        keyword: $("#demoReload").val()

                    } //设定异步数据接口的额外参数

                });
                $("table tr").css({
                    "background": "#19A094",
                    "color": "white"
                });
            });
            $("table tr").css({
                "background": "#19A094",
                "color": "white"
            });
        });
    </script>

</body>

</html>